def BF(s1,s2):
    i = 0
    j = 0
    while(i < len(s1) and j < len(s2)):
        if(s1[i] ==  s2[j]):
            i += 1
            j += 1
        else:
            i = i - j + 1
            j = 0
    if(j >= len(s2)):
        d = i - len(s2)
        print("存在该词汇，该词汇的位置在原文中第",d+1,"位")
    else:
        print("该词条不存在。")

if __name__ == "__main__":
    a1="abcaaaabbbbcccabcbabdbcsbbbbnnn"
    a2='n'
    b=BF(a1,a2)
    print(b)
    s1 = "ababcabcacbab"
    s2 = "abcac"
    print(BF(s1,s2))
     
      

         
              
              
         
           
            
    
        
    
        
  
 
